package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Person P =new Person();
        P.sayHello();

        Class cls=Class.forName("reflect.Person");
        Object o = cls.newInstance();

        Method method=cls.getMethod("sayHello");

        method.invoke(o);

    }
}
